package com.example.teatea.controller;

import com.example.teatea.ChangePswApp;
import com.example.teatea.MainApp;
import com.example.teatea.project.Good;
import javafx.event.ActionEvent;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.stage.Modality;
import javafx.stage.Stage;

import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;

public class SeatController {
    public Button one;
    public Button two;
    public Button three;
    public Button four;
    public Button five;
    public Button six;
    public Label backStage;
    public Label changePsw;
    public static HashMap<Good,Integer> hashMap = new HashMap<>();
    public static int nowSeat = 0;

    public void toBackStage(MouseEvent mouseEvent) throws Exception {
        Stage stage = (Stage) one.getScene().getWindow();
        stage.close();
        MainApp mainApp = new MainApp();
        mainApp.start(stage);
    }

    public void toChangePsw(MouseEvent mouseEvent) throws Exception {
        Stage stage = new Stage();
        ChangePswApp changePswApp = new ChangePswApp();
        changePswApp.start(stage);
    }

    public void toOrder1(ActionEvent actionEvent) throws IOException {
        nowSeat = 1;
        try {
            openOrder();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void toOrder2(ActionEvent actionEvent) {
        nowSeat = 2;
        try {
            openOrder();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void toOrder3(ActionEvent actionEvent) {
        nowSeat = 3;
        try {
            openOrder();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void toOrder4(ActionEvent actionEvent) {
        nowSeat = 4;
        try {
            openOrder();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void toOrder5(ActionEvent actionEvent) {
        nowSeat = 5;
        try {
            openOrder();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void toOrder6(ActionEvent actionEvent) {
        nowSeat = 6;
        try {
            openOrder();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void openOrder() throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/com/example/teatea/fxml/Order.fxml"));//定位界面文件
        Scene scene = new Scene(fxmlLoader.load());//加载界面到Scene场景对象
        Stage stage = new Stage();//创建Stage窗体对象
        stage.setScene(scene);//设置窗体的场景
        // stage.initStyle(StageStyle.TRANSPARENT);
        //设置窗口标题
        stage.setTitle("点单");
        //设置窗体不关闭不能使用其它窗体
        stage.initModality(Modality.APPLICATION_MODAL);
        //设置窗口大小不能改变
        stage.setResizable(false);
        stage.show();//显示窗体
    }
}
